<template>
  <div class="middle" v-if="bannerList.length > 0 && enBannerList.length > 0">
    <div class="title">{{ $t("common.technology") }}</div>

    <div class="detail">
      <div class="bg">
        <img
          :src="locale === 'zh-cn' ? bannerList[0].image : enBannerList[0].image"
          alt="" v-if="!bannerList[0].image?.includes('.mp4') && !enBannerList[0].image?.includes('.mp4')"
        />

        <video width="320" height="240" controls autoplay muted v-else style="width: 100%;height: 100%;">
          <source :src="locale === 'zh-cn' ? bannerList[0].image : enBannerList[0].image" type="video/mp4">
          您的浏览器不支持 HTML5 video 标签。
        </video>
      </div>

      <div class="infoBox">
        <el-button
          type="primary"
          class="lookBtn"
          @click="jumpTo(locale === 'zh-cn' ? bannerList[0].url : enBannerList[0].url)"
          >{{ $t("common.more") }}</el-button
        >

        <div class="subTitle">{{ $t("common.desc1") }}</div>
        <div class="desc">{{ $t("common.desc2") }}</div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { reactive, ref, onMounted } from "vue";
import axios from "axios";
import { useI18n } from "vue-i18n";
const I18n = useI18n();
const { locale } = useI18n();
import { useRouter } from "vue-router";
const router = useRouter();
// 跳转页面
const jumpTo = (path) => {
  router.push(path);
};

const bannerList = ref([]);
const getBanner = async () => {
  try {
    const res = await axios.get(`${apiUrl}/pc/get_keji_xinpin_image`, {
      headers: {
        "Authori-zation": `Bearer ${getToken()}`,
      },
    });

    if (res.data.status === 200) {
      bannerList.value = res.data.data.list;
    }
  } catch (e) {}
};

const enBannerList = ref([]);
const getEnBanner = async () => {
  try {
    const res = await axios.get(`${apiUrl}/pc/get_en_keji_xinpin_image`, {
      headers: {
        "Authori-zation": `Bearer ${getToken()}`,
      },
    });

    if (res.data.status === 200) {
      enBannerList.value = res.data.data.list;
    }
  } catch (e) {}
};

onMounted(() => {
  getBanner();
  getEnBanner();
});
</script>

<style scoped lang="scss">
.middle {
  margin-top: 60px;

  .title {
    font-size: 32px;
    // font-weight: bold;
    text-align: center;
    margin-bottom: 40px;
  }

  .detail {
    width: 100%;
    height: 650px;
    position: relative;

    .bg {
      width: 100%;
      height: 100%;
      overflow: hidden;

      img {
        width: 100%;
      }
    }

    .infoBox {
      position: absolute;
      left: 50%;
      bottom: 150px;
      transform: translate(-50%, 0);
      text-align: center;
      color: #fff;

      .subTitle {
        font-size: 32px;
        font-weight: bold;
        margin-top: 30px;
        margin-bottom: 10px;
      }

      .desc {
        font-size: 14px;
      }
    }
  }
}

.lookBtn {
  width: 150px;
  height: 41px;
  line-height: 41px;
}
</style>
